using System.Collections.ObjectModel;
using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using NewUI.Component;
using SukiUI.Dialogs;

namespace NewUI.ViewModels;

public partial class PlcVariableViewModel : ViewModelBase
{

    private ISukiDialog _dialog;
    

    public IAvaloniaReadOnlyList<InvoiceViewModel> Invoices { get; } = new AvaloniaList<InvoiceViewModel>()
    {
        new(15364, "Jean", 156, true),
        new(45689, "Fantine", 82, false),
        new(15364, "Jean", 156, true),
        new(45689, "Fantine", 82, false),
        new(15364, "Jean", 156, true),
        new(45689, "Fantine", 82, false),
    };
    
    public ObservableCollection<string> Items { get; } = new()
    {
        "Item 1",
        "Item 2",
        "Item 3",
        "Item 4",
        "Item 5",
        "Item 6",
        "Item 7",
        "Item 8",
        "Item 9",
        "Item 10",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11",
        "Item 11"
        
    };
    
    [RelayCommand]
    public void OpenDialog()
    {
        var dialogBuilder = MainWindow.DialogManager.CreateDialog();
        VariableTest variableTest = new(this);
        dialogBuilder.WithViewModel(dialog =>  variableTest);
        _dialog = dialogBuilder.Dialog;
        dialogBuilder.TryShow();
    }

    [RelayCommand]
    public void CloseDialog()
    {
        _dialog.Dismiss();
    }
}

public partial class InvoiceViewModel : ObservableObject
{
    [ObservableProperty] private int _id;
    [ObservableProperty] private string? _billingName;
    [ObservableProperty] private int _amountPaid;
    [ObservableProperty] private bool _paid;

    public InvoiceViewModel(int id, string? billingName, int amountPaid, bool paid)
    {
        Id = id;
        BillingName = billingName;
        AmountPaid = amountPaid;
        Paid = paid;
    }
}